#include "types.h"
#include "defs.h"
#include "param.h"
#include "mmu.h"
#include "proc.h"
#include "x86.h"
#include "traps.h"
#include "spinlock.h"

const int SCREEN_X_MAX = 800;
const int SCREEN_Y_MAX = 600;
static unsigned short *VESA_ADDR = (unsigned short*)0xe0000000;
//unsigned short buffer[1024][768];

void 
draw_loading()
{
  int i;
  int j;
  for(i = 0; i < SCREEN_X_MAX;++i)
  {
    for(j = 0; j < SCREEN_Y_MAX;++j)
    {
      unsigned int offset = j * SCREEN_X_MAX + i;
      unsigned short a = 31;
      *(VESA_ADDR + offset) = (a << 12);
    }
  }
}

void
kbd_response()
{
  int i;
  int j;
  for(i = 0; i < SCREEN_X_MAX;++i)
  {
    for(j = 0; j < SCREEN_Y_MAX;++j)
    {
      unsigned int offset = j * SCREEN_X_MAX + i;
      unsigned short a = 31;
      *(VESA_ADDR + offset) = (a << 8);
    }
  }
}

void
mouse_response(int event)
{
  unsigned short a = 31;
  if(event == 1)
  {
    cprintf("event1\n");
    a = a << 4;
  }
  else if(event == 2)
  {
    cprintf("event2\n");
    a = a << 8;
  }
  else
    return;
  int i;
  int j;
  for(i = 0; i < SCREEN_X_MAX;++i)
  {
    for(j = 0; j < SCREEN_Y_MAX;++j)
    {
      unsigned int offset = j * SCREEN_X_MAX + i;
      *(VESA_ADDR + offset) = a;
    }
  }
}